import { AppBaseEntity } from 'src/shared/database/baseEntity';
import { Column, Entity } from 'typeorm';

// 收款方式
export enum PayType {
  // 平台微信
  PLATFORM_WECHAT = 'platform_wechat',
  // 店铺上传商户号
  STORE_MERCHANT_NUMBER = 'tenant_merchant_number',
}

@Entity({
  name: 'tenants',
  comment: '租户表',
})
export class Tenant extends AppBaseEntity {
  @Column({
    comment: '用户id',
    name: 'user_id',
  })
  userId: number;

  @Column({
    comment: '店铺名称',
    name: 'name',
  })
  name: string;

  @Column({
    comment: '店铺logo',
    name: 'logo',
    default: '',
  })
  logo: string;

  @Column({
    comment: '店铺描述',
    name: 'description',
    default: '',
  })
  description: string;

  // 租户联系人
  @Column({
    name: 'contact_name',
    comment: '租户所属人姓名',
  })
  contactName: string;

  // 租户联系电话
  @Column({
    name: 'contact_phone',
    comment: '租户所属人电话',
  })
  contactPhone: string;

  @Column({
    comment: '店铺过期时间',
    name: 'expired_at',
    type: 'bigint',
    default: 0,
  })
  expiredAt: number;

  // 租户状态
  @Column({
    name: 'status',
    comment: '租户状态',
    default: false, // false: 停用，true: 正常
  })
  status: boolean;

  @Column({
    comment: '收款方式',
    name: 'pay_type',
    type: 'enum',
    enum: PayType,
    default: PayType.PLATFORM_WECHAT,
  })
  payType: PayType;

  @Column({
    comment: '商户号',
    name: 'merchant_number',
    default: '',
  })
  merchantNumber: string;

  // 店铺地址

  // 省
  @Column({
    comment: '省',
    default: '',
  })
  province: string;

  // 市
  @Column({
    comment: '市',
    default: '',
  })
  city: string;

  // 区
  @Column({
    comment: '区',
    default: '',
  })
  district: string;

  @Column({
    comment: '店铺地址',
    name: 'address',
    default: '',
  })
  address: string;

  // 邀请人手机号
  @Column({
    name: 'inviter_phone',
    comment: '邀请人手机号',
    default: '',
  })
  inviterPhone: string;
}
